﻿using System;

namespace DNT.RavenQA.Core.Extensions
{
    public static class StringExtensions
    {
        public static Boolean IsNullOrWhiteSpace(this String source)
        {
            return String.IsNullOrWhiteSpace(source);
        }
        
        public static Boolean IsNotNullOrWhiteSpace(this String source)
        {
            return !String.IsNullOrWhiteSpace(source);
        }

        public static Boolean IsNotNullOrEmpty(this String source)
        {
            return !String.IsNullOrEmpty(source);
        }

        public static Boolean IsNullOrEmpty(this String source)
        {
            return String.IsNullOrEmpty(source);
        }

        public static void EnsureIsNotNullOrEmpty(this String obj, String parameterName = "")
        {
            obj.EnsureIsNotNull(parameterName);

            if (obj.IsEmpty())
                throw new ArgumentOutOfRangeException(parameterName.IsNullOrWhiteSpace() ? "no-name supplied" : parameterName);
        }
    }
}